<template>
    <div class="loading-overlay" v-if="show">
      <div class="loading-spinner">
        <!-- 这里用了简单的 CSS 动画实现加载 spinner，也可替换为图标或第三方组件 -->
        <div class="spinner"></div>
        <p class="loading-text" v-if="text">{{ text }}</p>
      </div>
    </div>
  </template>
  
  <script setup>
  import { defineProps } from 'vue';
  
  // 定义属性，控制是否显示、加载提示文本
  defineProps({
    show: {
      type: Boolean,
      default: false
    },
    text: {
      type: String,
      default: '加载中...'
    }
  });
  </script>
  
  <style scoped>
  .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
  }
  
  .loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 8px;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  .loading-text {
    margin: 0;
    color: #666;
  }
  </style>